from bs4 import BeautifulSoup								#导入BeautifulSoup
#下面代码示例都是用此文档测试
html_doc = """
<html><head><title>The Dormouse's story</title></head>
<body>
<p class="title"><b>The Dormouse's story</b></p>
<p class="story">Once upon a time there were three little sisters; and their names were
<a href="http://example.com/elsie" class="sister" id="link1">Elsie</a>,
<a href="http://example.com/lacie" class="sister" id="link2">Lacie</a> and
<a href="http://example.com/tillie" class="sister" id="link3">Tillie</a>;
and they lived at the bottom of a well.</p>
<p class="story">...</p>
"""
markup="<b><!--Hey, buddy. Want to buy a used parser?--></b>"	#字符串
soup=BeautifulSoup(html_doc,"lxml")						# 使用构造方法
soup1=BeautifulSoup(markup,"lxml")
tag=soup.a											#获取标签<a>
navstr=tag.string										#获取标签字符串
comment=soup1.b.string									#获取标签<b>的字符串
print(type(tag))											#Tag标签对象
print(type(comment))										#Comment对象包含文档注释内容
print(type(navstr))										#NavigableString对象包装字符串内容
print(type(soup))										#BeautifulSoup对象为文档的全部内容
